<?php
/*------------------------------------------------------------------------

# TZ Extension

# ------------------------------------------------------------------------

# author    DuongTVTemPlaza

# copyright Copyright (C) 2012 templaza.com. All Rights Reserved.

# @license - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL

# Websites: http://www.templaza.com

# Technical Support:  Forum - http://templaza.com/Forum

-------------------------------------------------------------------------*/

defined('_JEXEC') or die();

if($list):

    $doc    = JFactory::getDocument();
    if($params -> get('enable_jquery',0)):
        $doc -> addScript(JUri::base().'/modules/mod_tz_employee/js/jquery-1.9.1.min.js');
    endif;
    $doc -> addScript(JUri::base().'/modules/mod_tz_employee/js/jquery.bxslider.js');
    $doc -> addScript(JUri::base().'/modules/mod_tz_employee/js/jquery.fittext.js');
    $doc -> addStyleSheet(JUri::base().'/modules/mod_tz_employee/css/jquery.bxslider.css');
    $doc -> addStyleSheet(JUri::base().'/modules/mod_tz_employee/css/style.css');
?>
    <div class="employee<?php echo $moduleclass_sfx;?> TzEmployee carousel">
        <div class="tzemployee">
        <?php foreach($list as $item):?>
            <div class="slide">
                <div class="image">
                    <img src="<?php echo JUri::root().$item -> employee_image;?>"/>
                    <div class="bg_image"></div>
                </div>
                <div class="info">
                    <span class="name"><?php echo $item -> employee_name;?></span>
                    <span class="career"><?php echo $item -> employee_career;?></span>
                </div>
            </div>
        <?php endforeach;?>
        </div>
<!--        <div class="flexslider">-->
<!--            <ul class="slides">-->
<!--                --><?php //foreach($list as $item):?>
<!--                <li>-->
<!--                    <div class="slide">-->
<!--                        <div class="image">-->
<!--                            <img src="--><?php //echo JUri::root().$item -> employee_image;?><!--"/>-->
<!--                            <div class="bg_image"></div>-->
<!--                        </div>-->
<!--                        <div class="info">-->
<!--                            <span class="name">--><?php //echo $item -> employee_name;?><!--</span>-->
<!--                            <span class="career">--><?php //echo $item -> employee_career;?><!--</span>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </li>-->
<!--                --><?php //endforeach;?>
<!--            </ul>-->
<!--        </div>-->
    </div>

    <script>

        <?php
            $options    = new stdClass();

            //Default Option
            $options -> auto            = 'false';
            $options -> animationLoop   = 'false';
            $options -> controlNav      = 'false';
            $options -> directionNav    = 'false';
            $options -> pausePlay       = 'false';
            $options -> responsive      = 'true';

            if($params -> get('auto',1)):
                $options -> auto = 'true';
            endif;

            if($params -> get('responsive',1)):
                $options -> responsive = 'true';
            endif;

            if($params -> get('infiniteLoop',1)):
                $options -> infiniteLoop = 'true';
            endif;

            if($params -> get('controlNav',0)):
                $options -> controlNav = 'true';
            endif;

            if($params -> get('directionNav',1)):
                $options -> directionNav = 'true';
            endif;

            if($params -> get('slideshowSpeed',7000)):
                $options -> slideshowSpeed = $params -> get('slideshowSpeed',7000);
            endif;

            if($params -> get('animationSpeed',600)):
                $options -> animationSpeed = $params -> get('animationSpeed',600);
            endif;

            if($params -> get('pausePlay',0)):
                $options -> pausePlay = 'true';
            endif;

            if($params -> get('pauseText','Pause')):
                $options -> pauseText = '"'.$params -> get('pauseText','Pause').'"';
            endif;

            if($params -> get('playText','Play')):
                $options -> playText = '"'.$params -> get('playText','Play').'"';
            endif;

            if($params -> get('moveSlides',1)):
                $options -> moveSlides = $params -> get('moveSlides',1);
            endif;

            if($params -> get('itemWidth',207)):
                $options -> itemWidth = $params -> get('itemWidth',207);
//                $doc -> addStyleDeclaration('.TzEmployee .flexslider .image img{width: '.$options -> itemWidth.'px;}');
            endif;

            if($params -> get('minSlides',5)):
                $options -> minItems = $params -> get('minSlides',5);
            endif;

            if($params -> get('maxSlides',5)):
                $options -> maxItems = $params -> get('maxSlides',5);
            endif;

            if($params -> get('itemMargin',33)):
                $options -> slideMargin = $params -> get('slideMargin',33);
            endif;
        ?>
        jQuery(document).ready(function(){
            jQuery('.tzemployee').bxSlider({
                slideWidth: <?php echo $options -> itemWidth;?>,
                minSlides: <?php echo $options -> minItems;?>,
                maxSlides: <?php echo $options -> maxItems;?>,
                moveSlides: <?php echo $options -> moveSlides;?>,
                slideMargin: <?php echo $options -> slideMargin;?>,
                infiniteLoop: <?php echo $options -> infiniteLoop;?>,
                speed: <?php echo $options -> animationSpeed;?>,
                pause: <?php echo $options -> slideshowSpeed;?>,
                //auto
                auto: <?php echo $options -> auto?>,
                controls: <?php echo $options -> directionNav;?>, //Direction nav
                responsive: <?php echo $options -> responsive;?>,
                autoControls: <?php echo $options -> pausePlay;?>, //Pause/play control
                pager: <?php echo $options -> controlNav;?>,// Controls nav,
                startText: <?php echo $options -> playText;?>,
                stopText: <?php echo $options -> pauseText;?>
            });
            <?php if($params -> get('useFittext',1)):?>
            jQuery(".tzemployee .slide .name").fitText(0.69,{minFontSize: '18px', maxFontSize: '30px'});
            <?php endif;?>
        });
        jQuery(window).load(function(){
            if(jQuery('.TzEmployee').find('.bx-controls-direction')){
                jQuery('.TzEmployee').find('.bx-controls-direction a').css('top',jQuery('.bx-wrapper .slide .image').outerHeight(true)/2);
            }
        });
    </script>
<?php endif;?>